﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace Idlesoft.Utils
{
	public class CookieAwareWebClient : WebClient
	{
		public CookieAwareWebClient() : this(new CookieContainer()) { }
		public CookieAwareWebClient(CookieContainer container) { CookieContainer = container; }
		public CookieContainer CookieContainer { get; set; }
		protected override WebRequest GetWebRequest(Uri address)
		{
			WebRequest request = base.GetWebRequest(address);
			if (request is HttpWebRequest)
				(request as HttpWebRequest).CookieContainer = this.CookieContainer;
			return request;
		}
	}
}
